#define _CTR_SECURE_NO_WARNINGS 1
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
const int N = 1e5 + 10;
int arr[N];
int b[N * 10];
int n, m;
int main()
{
	scanf_s("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) {
		scanf_s("%d", &arr[i]);
		b[arr[i]]++;
	}
	while (m--) {
		int x, y;
		scanf_s("%d%d", &x, &y);
		b[arr[x]]--;
		arr[x] = y;
		b[y]++;
		int ma = -1000;
		for (int i = 1; i <= N * 10; i++) {
			if (ma < b[arr[i]]) {
				ma = b[arr[i]];
			}
		}
		cout << ma << endl;
		cout << ma * (ma - 1) * (ma - 2) / 6 << endl;
	}
	return 0;
}